package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @version v1.0.0
 * @Description:
 * @author: 赵英杰
 * @date: 2022.02.15
 * @since 1.0
 */
@Controller
@RequestMapping("/users")
public class UserController {
    @Autowired
    UserService userService;
    /*@GetMapping
    public String getUsers(Model model){
        List<User> users = userService.queryAll();
        model.addAttribute("users",users);
        return "user";
    }*/

    /**
     * @RequestParam :绑定请求参数
     *           value：绑定前端的参数
     *           required：是否必要的
     *           defaultValue：默认值
     * @param model
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping
    public String queryPage(Model model,
                            @RequestParam(value = "pageNum",required = false, defaultValue = "1") Integer pageNum,
                            @RequestParam(value = "pageSize",required = false, defaultValue = "2") Integer pageSize){
        Object obj = userService.queryPage(pageNum,pageSize);
        model.addAttribute("data",obj);
        return "userPro";
    }
}
